package com.example.servicegateway.sentinel;

import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;


/**
 * sentinel 配置类
 * 1.设置触发限流、降级规则，返回异常处理
 * 3.启动-Dcsp.sentinel.app.type=1，这样才能sentinel dashboard显示网关api分组配置
 *
 * @author K
 */
@Slf4j
@Configuration
public class SentinelRuleConfig {

    @PostConstruct
    public void loadRule() {
        // 限流，降级异常信息
        GatewayCallbackManager.setBlockHandler(new SentinelBlockRequestHandler());

        log.info("sentinel设置异常信息处理handler");
    }


}
